<?php
class Picture_data extends Data {
	private $alias = 'www-yueshihui-com';
	private $tb = 'picture';
	private $cols = array('id', 'pid', 'path', 'original_path', 'created_time');

	/**
	 * 添加景点图片
	 * @param unknown_type $cols
	 */
	public function add($id, array $cols = array()) {
		if(!($db = $this->connect($this->alias))) return false;
		
		$time = Func::time();
		$sql[] = 'INSERT INTO '.$this->tb.' (pid, path, original_path, created_time) VALUES ';
		foreach ($cols as $one) {
			$_sql[] = '("'.$id.'", "'.$one['path'].'", "'.$one['original_path'].'", "'.$time.'")';
		}
		$sql[] = implode(', ', $_sql);
		$sql = implode('', $sql);
		return $db->query($sql);
	}
	/**
	 * 获取产品信息
	 * @param unknown_type $params
	 */
	public function productInfo($params) {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->one($this->tb, $this->cols, $params);
	}
	/**
	 * 修改景点图片信息
	 * @param unknown_type $params
	 * @param unknown_type $cols
	 */
	public function edit($params, $cols) {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->update($this->tb, $cols, $params);
	}
	/**
	 * 删除景点图片
	 * @param unknown_type $params
	 */
	public function del($params) {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->delete($this->tb, $params);
	}
	/**
	 * 分页获取景点图片信息
	 * @param unknown_type $page
	 * @param unknown_type $size
	 * @param unknown_type $params
	 * @param unknown_type $orderBy
	 */
	public function page($page, $size, $params, $orderBy = '`id` DESC') {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->page($this->tb, $this->cols, $params, $orderBy, $page, $size);
	}
	
	/**
	 * 获取景点图片记录数
	 * @param unknown_type $params
	 */
	public function count($params) {
		if(!($db = $this->connect($this->alias))) return false;
		
		return $db->count($this->tb, $params);
	}
}